package com.cgtong.android.mvp.presenter;

import com.cgtong.android.mvp.contract.SignContract;
import com.cgtong.android.mvp.model.SignModel;
import com.zhouyou.http.callback.SimpleCallBack;
import com.zhouyou.http.exception.ApiException;
import com.zhouyou.http.model.ApiResult;

import java.util.List;

/**
 * Created by Tinwai on 2017/10/25.
 */
public class SignPresenter implements SignContract.Presenter {

    private SignContract.View mView;
    private SignModel model;

    public SignPresenter(SignContract.View mView) {
        this.mView = mView;
        this.model = new SignModel();
    }

    @Override
    public void sign() {
        model.sign(new SimpleCallBack<List<ApiResult>>() {
            @Override
            public void onError(ApiException e) {
                mView.signFail(e.getMessage());
            }

            @Override
            public void onSuccess(List<ApiResult> s) {
                mView.signSuccess();
            }
        });
    }

    @Override
    public void getSignInfo(String date) {
        model.getSignInfo(date, new SimpleCallBack<List<String>>() {
            @Override
            public void onError(ApiException e) {
            }

            @Override
            public void onSuccess(List<String> strings) {
                mView.getSignList(strings);
            }
        });
    }
}
